// statistics/data/index.js
import {
  getHyaqfxfbtj,
} from '../../../../api/statistics'
Component({
  data: {
    active: '',
    loading: false,
    startDate: '',
    endDate: '',
    form: {
      hy: '',
      zwbj: '',
      qh: '',
      startDate: '',
      endDate: ''
    },
    formName: {
      zwbj: '',
      qh: ''
    },
    info: {},
    value: 100,
    gradientColor: {
      '0%': '#ffd01e',
      '100%': '#ee0a24',
    },
    yhNum: 0
  },
  methods: {
    // 时间选择器返回数据
    dateChange(e) {
      this.setData({
        'form.startDate': e.detail.startDate,
        'form.endDate': e.detail.endDate,
      })
    },
    // 行业返回数据
    sshyChange(event) {
      this.setData({
        'form.hy': event.detail
      })
    },
    clear() {
      this.setData({
        form: {
          hy: '',
          zwbj: '',
          qh: '',
          startDate: '',
          endDate: ''
        },
        formName: {
          zwbj: '',
          qh: '',
        }
      })
      this.initData()
    },
    initData() {
      this.setData({
        loading: true
      })
      getHyaqfxfbtj({
        startdate: this.data.form.startDate,
        enddate: this.data.form.endDate,
        hy: this.data.form.hy,
      }).then(res => {
        let data = res.data;
        data.forEach(item=>{
          item.bl = parseInt(item.bl*100)
        })
        this.setData({
          info: data,
          loading: false
        })
      })
    },
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  ready() {
    this.initData()
  },
})